package com.glsc.ngateway.opmanage.controller.xinyi;


import com.glsc.ngateway.common.api.platform.resp.PlatformResponse;
import com.glsc.ngateway.common.base.domain.mysql.opmanagemain.xinyi.XinYiDefineLog;
import com.glsc.ngateway.opmanage.aspect.UserCache;
import com.glsc.ngateway.opmanage.dto.XinYiDefineDto;
import com.glsc.ngateway.opmanage.service.xinyi.XinYiDefineLogService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 新意指令自定义指令执行记录
 */
@RestController
@RequestMapping("/api/xinYiDefineLog")
@Slf4j
public class XinYiDefineLogController {

    @Resource
    private UserCache userCache;

    @Resource
    private XinYiDefineLogService xinYiDefineLogService;

    /**
     * 分页查找
     *
     * @param dto
     * @param request
     * @return
     */
    @PostMapping("/page")
    public PlatformResponse<Page<XinYiDefineLog>> page(@RequestBody XinYiDefineDto dto, HttpServletRequest request) {

        Map<String, Object> param = new HashMap<>();
        if (StringUtils.isNotBlank(dto.getName())) {
            param.put("LIKE_name", dto.getName());
        }
        if (StringUtils.isNotBlank(dto.getType())) {
            param.put("LIKE_type", dto.getType());
        }
        Page<XinYiDefineLog> page = xinYiDefineLogService.page(dto.getPageNo(), dto.getPageSize(), param);

        return PlatformResponse.successData(page);
    }


}
